/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package mx.unam.aragon.config;

import javax.persistence.EntityManagerFactory;
import mx.unam.aragon.domain.persistence.AppEntityManagerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;

/**
 * @author erico
 */
@Configuration
public class AppConfig {

    @Bean
    EntityManagerFactory entityManagerFactory() {
        return AppEntityManagerFactory.entityManagerFactory();
    }

    @Bean
    JpaTransactionManager transactionManager() {
        final JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(entityManagerFactory());
        return transactionManager;
    }
}